import { defineStore } from 'pinia';
import type { EditorType } from '@/types';

export const useSettingsStore = defineStore('settings', {
  state: () => ({
    theme: 'light',
    editorType: 'markdown' as EditorType,
    fontSize: 16,
    language: 'zh-CN',
    sidebarCollapsed: false,
  }),
  
  actions: {
    setTheme(theme: string) {
      this.theme = theme;
      document.documentElement.setAttribute('data-theme', theme);
    },
    
    setEditorType(type: EditorType) {
      this.editorType = type;
    },
    
    setFontSize(size: number) {
      this.fontSize = size;
    },
    
    setLanguage(lang: string) {
      this.language = lang;
    },
    
    toggleSidebar() {
      this.sidebarCollapsed = !this.sidebarCollapsed;
    }
  },
  
  persist: true,
}); 